//
//  CXProjectCollectionViewCell.m
//  GiftThat
//
//  Created by ChuXiang on 16/1/7.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "CXProjectCollectionViewCell.h"
@interface CXProjectCollectionViewCell ()
@property (nonatomic, strong) UIImageView *image;
@end
@implementation CXProjectCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.image = [UIImageView new];
        self.image.layer.cornerRadius = self.height / 10;
        self.image.layer.masksToBounds = YES;
        [self addSubview:self.image];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];

    self.image.frame = CGRectMake(10, 0, self.width - 20, self.height);
}

- (void)setModel:(CXClassProModel *)model {
    if (self.model != model) {
        if (model) {
            [self.image sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url]];  
        }
    }
    //    夜间模式换cell得背景颜色
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Color"] isEqualToString:@"BlackColor"]) {
        self.backgroundColor = [UIColor colorWithRed:35 / 255.0 green:34 / 255.0 blue:38 / 255.0 alpha:1.0];
        
    }else{
        self.backgroundColor =  [UIColor whiteColor];
    }

}
@end
